﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
//using System.Threading.Tasks;
using System.Windows.Forms;

namespace TRicheControl.WinformControl
{
    public partial class RicheMenuBarButtonItem : RicheMenuBarItem
    {
        public RicheMenuBarButtonItem()
        {
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs pe)
        {
            DrawItem(pe);
        }

        public override Size GetSize()
        {
            return new Size(70 ,base.Height);
        }

        public void DrawItem(PaintEventArgs pe)
        {
            if (this.Enabled == true)
            {
                GraphicsStyle.Styles.ButtonStyle.DrawEnabelMenuBarItem(pe.Graphics, pe.ClipRectangle);
            }
            else
            {
                GraphicsStyle.Styles.ButtonStyle.DrawUnEnabelMenuBarItem(pe.Graphics, pe.ClipRectangle);
            }
            GraphicsStyle.Styles.ButtonStyle.DrawString(this.Text, this.Font, this.ForeColor, pe.Graphics, pe.ClipRectangle);
        }

        protected override void OnMouseEnter(EventArgs e)
        {
            if (this.Enabled == true)
            {
                GraphicsStyle.Styles.ButtonStyle.DrawMouseEnterMenuBarItem(this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            }
            else
            {
                GraphicsStyle.Styles.ButtonStyle.DrawUnEnabelMenuBarItem(this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            }
            GraphicsStyle.Styles.ButtonStyle.DrawString(this.Text, this.Font, this.ForeColor, this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            if (this.Enabled == true)
            {
                GraphicsStyle.Styles.ButtonStyle.DrawEnabelMenuBarItem(this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            }
            else
            {
                GraphicsStyle.Styles.ButtonStyle.DrawUnEnabelMenuBarItem(this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            }
            GraphicsStyle.Styles.ButtonStyle.DrawString(this.Text, this.Font, this.ForeColor, this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            base.OnMouseLeave(e);
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (this.Enabled == true)
            {
                GraphicsStyle.Styles.ButtonStyle.DrawMouseDownMenuBarItem(this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            }
            else
            {
                GraphicsStyle.Styles.ButtonStyle.DrawUnEnabelMenuBarItem(this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            }
            GraphicsStyle.Styles.ButtonStyle.DrawString(this.Text, this.Font, this.ForeColor, this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            base.OnMouseDown(e);
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (this.Enabled == true)
            {
                GraphicsStyle.Styles.ButtonStyle.DrawMouseEnterMenuBarItem(this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            }
            else
            {
                GraphicsStyle.Styles.ButtonStyle.DrawUnEnabelMenuBarItem(this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            }
            GraphicsStyle.Styles.ButtonStyle.DrawString(this.Text, this.Font, this.ForeColor, this.Graphics, new Rectangle(0, 0, this.Bounds.Width, this.Bounds.Height));
            base.OnMouseUp(e);
        }
    }
}
